package com.hzdl.service;

import com.hzdl.bean.Project;
import com.hzdl.bean.Room;
import com.hzdl.dao.ProjectDao;
import com.hzdl.dao.RoomDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * author:Administrator
 * date:2018\9\5 0005
 * description:
 */
@Service
public class RoomService {
    @Autowired
    private RoomDao roomDao;
    @Autowired
    private ProjectDao projectDao;
    //根据pid获取该项目下的房间
    public List<Room> getAllRoomsByPid(int pid){
        return roomDao.getAllRoomsByPid(pid);
    }
    //根据房间id获取房间
    public Room getRoomByRid(int rid){
        return roomDao.getRoomByRid(rid);
    }
    //编辑房间信息
    public boolean editRoom(String rname,double size,double rented_size,int rid){
        roomDao.editRoom(rname, size, rented_size, rid);
        return true;
    }
    //添加房源
    public void addRoom(int pid,Room room){
        Project project = projectDao.getProjectById(pid);
        roomDao.addRoom(room);
        //double rental_size = project.getRental_size()+room.getRent_size();
        //roomDao.updateProjectTotalArea(rental_size,pid);
    }
    //获取待出租的房间信息
    public List<Room> getAllRooms(int is_rent){
        return  roomDao.getAllRooms(0);
    }
}
